import 'package:ft_reader/beans/banner_item_bean.dart';
import 'base_bloc.dart';
import 'package:rxdart/rxdart.dart';

class BannerBloc extends BaseBloc {
  //
  final _bannerFetcher = PublishSubject<List<BannerItemBean>>();

  // 监听
  Observable<List<BannerItemBean>> get bannerItems => _bannerFetcher.stream;

  void fetchBannerItems(String sex) async {
    List<BannerItemBean> datas = await netApi.fetchBannerItems(sex);
    if (!_bannerFetcher.isClosed){
      _bannerFetcher.sink.add(datas);
    }
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _bannerFetcher?.close();
  }
}
